<template>
  <span class="cms-icon iconfont" :class="clsName" :style="{ fontSize: size + 'px' }"></span>
</template>

<script>
import { defineComponent, computed } from 'vue'
export default defineComponent({
  name: 'Icon',
  props: {
    name: {
      type: String,
      required: true,
      default: ''
    },
    size: {
      type: Number,
      default: 16
    },
    preIndex: {
      type: String,
      default: 'icon'
    }
  },
  setup(props) {
    const clsName = computed(() => {
      let r = ''
      if (props.name) {
        r = `${props.preIndex}-${props.name}`
      }
      return r
    })
    return { clsName }
  }
})
</script>

<style lang="scss" scoped>
.cms-icon {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  position: relative;
}
</style>
